<template>
    <div>
        <VHeader title="修改密码" />
        <div class="title">修改密码</div>
        <div class="form">
            <div class="flex">
                <div class="left">原密码：</div>
                <div class="right"><input type="password" v-model="form.old" /></div>
            </div>
            <div class="flex">
                <div class="left">新密码：</div>
                <div class="right"><input type="password" v-model="form.new" /></div>
            </div>
            <div class="flex">
                <div class="left">确认新密码：</div>
                <div class="right"><input type="password" v-model="form.new2" /></div>
            </div>
        </div>
        <div class="flex flex-center buttons">
            <button class="apply" @click="submit">提交修改</button>
        </div>
    </div>
</template>

<script>
    import {Dialog} from 'vant'
    import {removeLocVal} from "../../utils/utils";
    export default {
        name: "Feedback",
        data(){
            return {
                form: {old: '', 'new': '', new2: ''},
                contents: '',
            }
        },
        methods:{
            async submit(){
                await this.$http({
                    ...this.form,
                    method: 'api.mine.passwordUpdate',
                });
                Dialog.alert({
                    title: '成功',
                    message: '修改密码成功！'
                }).then(() => {
                    removeLocVal('token');
                    this.$router.push('/login');
                });
            }
        },
    };
</script>

<style lang="scss" scoped>
    .title {
        padding: 0.3rem;
        line-height: 120%;
        font-size: 120%;
        border-bottom: 1px solid #CBCACA;
        margin-bottom: 0.2rem;
        color:#CA5B4D;
    }
    .form {
        padding:0 0.3rem;
        > .flex {
            padding: 0.1rem 0;
        }
        .left {
            min-width: 80px;
            padding: 10px 0 10px;
            text-align: right;
        }
        .right {
            flex-grow: 1;
            input {
                line-height: 30px;
            }
            input, textarea {
                width:100%;
                border: 1px solid #e3e3e3;
            }
        }
    }
    .buttons {
        margin-top: 2rem;
        .apply {
            border:0;
            color: white;
            font-size: 130%;
            padding: 0.2rem 0;
            width: 85%;
            border-radius: 4px;
            background-color: #F65D5D;
        }
    }
</style>